package com.projectbox.web;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.projectbox.model.Resource;
import com.projectbox.service.ResourceService;
import com.projectbox.service.UserService;

@Controller
@RequestMapping("/resourceList")
public class ResourceListAPIController {
	
	private Logger logger = LoggerFactory.getLogger(getClass()); 
	private ResourceService resourceService;
	private UserService userService;
	
	public void setResourceService(ResourceService resourceService){
		this.resourceService = resourceService;
	}
	
	public void setUserService(UserService userService) {
		this.userService = userService;
	}
	
	@RequestMapping(method = RequestMethod.GET)
	@ResponseBody
	public List<Resource> getUserResources(){
		return resourceService.getLatestResources(userService.getCurrentUser().getId());
	}
}
